<template>
	<view>
		<input type="text" v-model= "username" />
		<input type="password" v-model="password"/>
		<button type="default" @tap="login">login</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				username:"",
				password:""
				
			}
		},
		methods: {
			login(){
				uni.request({
					url: 'http://localhost:8000/login/',
					method: 'POST',
					data: {username:this.username,password:this.password},/*data*/
					success: res => {
						if (res.data['code']=='1000'){
							
							uni.showToast({
								title:res.data['msg'] /*responnse*/
							});
							// uni.navigateTo({
							// 	url: '/pages/index/index'
							// });
						}else{
							uni.showToast({
								title: res.data['msg']
							});
						}
						
						
					},
					fail: () => {},
					complete: () => {}
				});
			}
		}
	}
</script>

<style>
input{
		border: #808080 1px solid;
		margin: 10rpx 20rpx;
		
		background-color:#4CD964;
		height: 100rpx;
	}
</style>
